﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net.Http;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using Water.Model;
using System.Collections.Generic;

namespace Water.Rest.UnitTest
{
    [TestClass]
    public class BridgePipeLedgerUnitTest
    {
        string basUrl = "http://localhost:46518/";

        [TestMethod]
        public void GetBridgePipeLedgersCount()
        {
            string url = basUrl + "GetBridgePipeLedgersCount";
            var requestJson = JsonConvert.SerializeObject(new BridgePipeLedger { });
            HttpContent httpContent = new StringContent(requestJson);
            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var httpClient = new HttpClient();
            var responseJson = httpClient.PostAsync(url, httpContent)
                .Result.Content.ReadAsStringAsync().Result;
        }

        [TestMethod]
        public void GetBridgePipeLedgers()
        {
            string url = basUrl + "GetBridgePipeLedgers/1/2";
            BridgePipeLedger info = new BridgePipeLedger();
            //info.Ve = new Valve() { LOCATION = "哈哈" };
            var requestJson = JsonConvert.SerializeObject(info);
            HttpContent httpContent = new StringContent(requestJson);

            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var httpClient = new HttpClient();
            var responseJson = httpClient.PostAsync(url, httpContent)
                .Result.Content.ReadAsStringAsync().Result;
            var mr = JsonConvert.DeserializeObject<IList<BridgePipeLedger>>(responseJson);
        }

        [TestMethod]
        public void AddBridgePipeLedger()
        {
            string url = basUrl + "AddBridgePipeLedger";
            BridgePipeLedger info = new BridgePipeLedger { EpcNo = "01", Memo="aa", ValveNull="v", OpertionEmp="11" };
            //mr.Mt = new Meter { EpcNo = "01", METERID = "1" };
            var requestJson = JsonConvert.SerializeObject(info);
            HttpContent httpContent = new StringContent(requestJson);

            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var httpClient = new HttpClient();
            var responseJson = httpClient.PostAsync(url, httpContent)
                .Result.Content.ReadAsStringAsync().Result;
        }
    }
}
